import request from "@/utils/request";
import type { AxiosPromise } from "axios";
//获取角色详情
export const _getRoleInoById = async (params: object): Promise<RoleInfo> => {
  const response = await request({
    url: '/role/query-role-byId',
    method: 'GET',
    params: params,
  });
  return response.data; // Assuming the response contains the data in this format
}


//获取角色列表
export const _getRoleList = async (): AxiosPromise<RoleInfo[]> => {
  return request({
    url: '/role/query-role-list',
    method: 'GET',
  });
}


export const _getRoleMenuInfoByRoleId =  async (roleId: string): Promise<AxiosPromise> => {
  const response = await request({
    url: '/role/query-role-menu-infos-by-roleId',
    method: 'GET',
    params: {
      roleId: roleId
    }
  });
  return response; // Assuming the response contains the data in this format
}


export const _saveRoleInfo = async(param : object) : Promise<AxiosPromise> =>{
  const response = await request({
    url: '/role/insert',
    method: 'POST',
    data: param
  });
  return response;
}

export const _updateRoleInfo = async(param : object) : Promise<AxiosPromise> =>{
  const response = await request({
    url: '/role/modify',
    method: 'POST',
    data: param
  });
  return response;
}

export interface RoleInfo {
    id:string;
    roleKey: string;
    roleName :string;
    status : string;
    dataScope : string;
  }
